package com.attendance.controller;

import com.attendance.model.Apply;
import com.attendance.model.Employee;
import com.attendance.model.Type;
import com.attendance.model.Vacation;
import com.attendance.service.ITypeService;
import com.attendance.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.sql.Date;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by inuyasha on 2016/11/17.
 */
@RestController
@EnableAutoConfiguration
public class TestController {

    @Autowired
    private TestService testService;

    @Autowired
    private ITypeService typeService;

//    @Autowired
//    private static final SimpleDateFormat DATE_PARSER = new SimpleDateFormat("YYYY-MM-DD");

//
//    @RequestMapping("/")
//    public PageInfo hello(){
//        PaginationUtil.preset(1,10,"id","asc");
//        List<Type> list = typeService.getAll();
//        PageInfo pageInfo = new PageInfo(list);
//        return pageInfo;
//    }

    @RequestMapping(value="/{employeeId}/info",method= RequestMethod.GET)
    public List<Employee> getEmployeeInfo(@PathVariable Integer employeeId){
        List<Employee> li = new ArrayList<Employee>();
        return  li;
    }


    @RequestMapping(value="/empl/{employeeId}/card_record/{start}_{end}",method= RequestMethod.GET)
    public List<Apply> getRecord(@PathVariable Integer employeeId, @PathVariable String start, @PathVariable String end) throws ParseException {
        System.out.println(employeeId);
        System.out.println(start);
        System.out.println(end);
        List<Apply> li = new ArrayList<>();
        Apply a = new Apply();
        a.setId(3);
        a.setEndTime(Date.valueOf("2016-12-12"));
        a.setStartTime(Date.valueOf("2016-12-10"));
        a.setType(3);
        a.setState(4);
        a.setInstructions1("快回来");
        a.setInstructions2("快回来");
        a.setInstructions3("快回来");
        a.setTotal(2);
        a.setReason("家里猫生孩子");
        a.setUid(4);
        li.add(a);
        li.add(a);
        return  li;
    }
    @RequestMapping(value = "/empl/{employeeId}/vacation_left", method = RequestMethod.GET)
    public List<Vacation> getRemainVacationByUid(@PathVariable Integer employeeId){
        Vacation v = new Vacation();
        v.setUid(23);
        v.setId(2);
        v.setNumber(23);
        v.setType(23);
        List<Vacation> li = new ArrayList<Vacation>();
        li.add(v);
        li.add(v);
        return li;
    }
    @RequestMapping(value = "/vacation_type/", method = RequestMethod.GET)
    public List<Type> getAllType(){
        Type t = new Type();
        t.setMemo("memo content");
        t.setId(3);
        t.setDiscount((float) 0.8);
        t.setName("病假");
        List<Type> li = new ArrayList<>();
        li.add(t);
        li.add(t);


        return li;
    }
}
